// 导入instance
import instance from '@/utils/axios'

// 查询文章列表
function getArticleCategory () {
  return instance({
    url: '/admin/category/list',
    method: 'get'
  })
}

// 新增文章分类
function addArticleCategory ({ name, slug }) {
  return instance({
    url: '/admin/category/add',
    method: 'post',
    data: { name, slug }
  })
}

// 编辑文章类别
function editArticleCategory ({ id, name, slug }) {
  return instance({
    url: '/admin/category/edit',
    method: 'post',
    data: { id, name, slug }
  })
}

// 删除文章类别
function deleteArticleCategory (id) {
  return instance({
    url: '/admin/category/delete',
    method: 'post',
    data: { id }
  })
}

export {
  getArticleCategory,
  addArticleCategory,
  editArticleCategory,
  deleteArticleCategory
}

// 文章搜索
function getArticleList (obj) {
  return instance({
    url: '/admin/article/query',
    method: 'get',
    params: obj
  })
}

// 发布文章
function publishArticle (obj) {
  return instance({
    url: '/admin/article/publish',
    method: 'post',
    data: obj
  })
}

// 文章编辑
function editArticle (obj) {
  return instance({
    url: '/admin/article/edit',
    method: 'post',
    data: obj
  })
}
// 文章删除
function deleteArticle (id) {
  return instance({
    url: '/admin/article/delete',
    method: 'post',
    data: {
      id
    }
  })
}

export { getArticleList, publishArticle, editArticle, deleteArticle }
